package com.retirement.activity.controller;

import com.retirement.activity.domain.OldActivity;
import com.retirement.activity.dto.OldActivityAddDto;
import com.retirement.activity.dto.OldActivityDto;
import com.retirement.activity.service.IOldActivityService;
import com.retirement.activity.vo.OldActivityVo;
import com.retirement.common.core.controller.BaseController;
import com.retirement.common.core.domain.AjaxResult;
import com.retirement.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lijy
 * @since 2023-12-22
 */

@Api(value = "活动管理", tags = "活动管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("/activity")
public class OldActivityController extends BaseController {

    private final IOldActivityService iOldActivityService;

    @PostMapping
    @ApiOperation(value = "新增活动")
    public AjaxResult addActivity(@RequestBody OldActivity dto){
        return AjaxResult.success(iOldActivityService.addActivity(dto));
    }

    @PutMapping
    @ApiOperation(value = "修改活动")
    public AjaxResult updateActivity(@RequestBody OldActivityAddDto dto){
        return AjaxResult.success(iOldActivityService.updateActivity(dto));
    }

    @GetMapping("/page")
    @ApiOperation(value = "分页获取活动信息")
    public TableDataInfo listOldActivity(OldActivityDto dto){
        startPage();
        return getDataTable(iOldActivityService.listOldActivity(dto));
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "详情信息查询")
    public OldActivityVo getDetail(@PathVariable("id") String id){
        return iOldActivityService.getDetail(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除信息")
    public AjaxResult deleteActivity(@PathVariable("id") String id){
        return AjaxResult.success(iOldActivityService.deleteOldActivity(id));
    }

}
